#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

int h, w;
int x1, y1, x2, y2;
string s;

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    x1 = -1, y1 = -1, x2 = -1, y2 = -1;
    cin >> h >> w;
    for(int i = 1; i <= h; i ++){
        cin >> s;
        for(int j = 1; j <= w; j ++){
            if(s[j - 1] == 'o'){
                if(x1 == -1){
                    x1 = i, y1 = j;
                }else{
                    x2 = i, y2 = j;
                }
            }
        }
    }

    cout << abs(x1 - x2) + abs(y1 - y2) << '\n';



    return 0;
}